(define (tree-map m items)
    (let (
            (car-items (car items))
            (cdr-items (cdr items))
        )
        
        (cond 
            ((null? items) `())           
            ((pair? car-items)
                (cons 
                    (tree-map m car-items)
                    (if (pair? cdr-items)
                        (tree-map m cdr-items)
                        `()
                    )
                )
            )
            (else
                (cons 
                    (m car-items)
                    (if (pair? cdr-items)
                        (tree-map m cdr-items)
                        `()
                    )
                ) 
                
            )    
        )
        
    )
)

(define (square x)
    (* x x)
)
(define (square-tree tree)
    (tree-map square tree)
)

(display 
    (square-tree
        (list 1 (list 2 (list 3 4) 5) (list 6 7))
    )
)
(exit)